﻿using System;
using System.Collections.Generic;
using System.Text;
using FDSimpleModelGenerator.Logging;
using Microsoft.Extensions.DependencyInjection;

namespace FDSimpleModelGenerator.Aop
{
    /// <summary>
    /// Aop上下文
    /// </summary>
    public class AopContext
    {
        private AopContext() { }

        private static AopContext _current = new AopContext();

        public static AopContext Current => _current;

        private IServiceProvider _provider;

        public void Initialize(IServiceProvider provider)
        {
            _provider = provider;
            //AopOptions = provider.GetService<AopOptions>();
            //Logger = provider.GetService<ISystemLog<SystemLogAttribute>>();
        }

        /// <summary>
        /// 日志系统拦截日志
        /// </summary>
        public ISystemLog<SystemLogAttribute> GetLogger() => _provider.GetService<ISystemLog<SystemLogAttribute>>();

        /// <summary>
        /// Aop选项
        /// </summary>
        public AopOptions GetAopOptions() => _provider.GetService<AopOptions>();
    }
}
